package common;

import Dao.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class Util {
    public static User checkLoginStatus (HttpServletRequest req){
        // 判断是否登录了. 如果能够拿到 Session, 并且拿到 Session 里的 user对象,就认为是登录状态
        HttpSession session = req.getSession(false);
        if(session == null){
            // 没有登录的情况
            return null;
        }
        User user = (User) session.getAttribute("user");

        return user;
    }

}
